/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package generated_entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author aav
 */
@Entity
@Table(name = "TEMPLATES", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"CURRENCY_ID", "BANK_REGION_ID"})})
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Templates.findAll", query = "SELECT t FROM Templates t"),
    @NamedQuery(name = "Templates.findByTemplateId", query = "SELECT t FROM Templates t WHERE t.templateId = :templateId"),
    @NamedQuery(name = "Templates.findByPurchaseTemplateText", query = "SELECT t FROM Templates t WHERE t.purchaseTemplateText = :purchaseTemplateText"),
    @NamedQuery(name = "Templates.findBySaleTemplateText", query = "SELECT t FROM Templates t WHERE t.saleTemplateText = :saleTemplateText")})
public class Templates implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    //@Basic(optional = false)
    //@NotNull
    @Column(name = "TEMPLATE_ID", nullable = false, precision = 0, scale = -127)
    private BigDecimal templateId;
    @Size(max = 2048)
    @Column(name = "PURCHASE_TEMPLATE_TEXT", length = 2048)
    private String purchaseTemplateText;
    @Size(max = 2048)
    @Column(name = "SALE_TEMPLATE_TEXT", length = 2048)
    private String saleTemplateText;
    @OneToMany(mappedBy = "templateId")
    private Collection<ErrorReports> errorReportsCollection;
    @JoinColumn(name = "CURRENCY_ID", referencedColumnName = "CURRENCY_ID", nullable = false)
    @ManyToOne(optional = false)
    private Currencies currencyId;
    @JoinColumn(name = "BANK_REGION_ID", referencedColumnName = "BANK_REGION_ID", nullable = false)
    @ManyToOne(optional = false)
    private BanksInRegions bankRegionId;

    public Templates() {
    }

    public Templates(BigDecimal templateId) {
        this.templateId = templateId;
    }

    public BigDecimal getTemplateId() {
        return templateId;
    }

    public void setTemplateId(BigDecimal templateId) {
        this.templateId = templateId;
    }

    public String getPurchaseTemplateText() {
        return purchaseTemplateText;
    }

    public void setPurchaseTemplateText(String purchaseTemplateText) {
        this.purchaseTemplateText = purchaseTemplateText;
    }

    public String getSaleTemplateText() {
        return saleTemplateText;
    }

    public void setSaleTemplateText(String saleTemplateText) {
        this.saleTemplateText = saleTemplateText;
    }

    @XmlTransient
    public Collection<ErrorReports> getErrorReportsCollection() {
        return errorReportsCollection;
    }

    public void setErrorReportsCollection(Collection<ErrorReports> errorReportsCollection) {
        this.errorReportsCollection = errorReportsCollection;
    }

    public Currencies getCurrencyId() {
        return currencyId;
    }

    public void setCurrencyId(Currencies currencyId) {
        this.currencyId = currencyId;
    }

    public BanksInRegions getBankRegionId() {
        return bankRegionId;
    }

    public void setBankRegionId(BanksInRegions bankRegionId) {
        this.bankRegionId = bankRegionId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (templateId != null ? templateId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Templates)) {
            return false;
        }
        Templates other = (Templates) object;
        if ((this.templateId == null && other.templateId != null) || (this.templateId != null && !this.templateId.equals(other.templateId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return bankRegionId.toString() + " " + currencyId.toString();
    }
    
}
